package com.tanxin.bill.common.base;

import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.blankj.utilcode.util.BarUtils;
import com.tanxin.bill.R;
import com.tanxin.bill.common.api.Contacts;

/**
 * Created by TANXIN on 2017/7/16.
 */
public abstract class BaseTitleActivity extends BaseActivity {

    protected Toolbar toolbar;
    protected FrameLayout activityContainer;

    @Override
    protected void setBaseView() {
        contentView = LayoutInflater.from(this).inflate(R.layout.base_title_activity, null);
        setContentView(contentView);
        activityContainer = findViewById(R.id.activity_container);
        toolbar = findViewById(R.id.toolbar);
        activityContainer.addView(LayoutInflater.from(this).inflate(bindLayout(), activityContainer, false));
        toolbar.setTitle(setTitle());
        toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.themeColor));

        //设置沉浸状态栏
        BarUtils.setStatusBarColor(this, ContextCompat.getColor(getContext(), R.color.themeColor), Contacts.DEFAULT_ALPHA);
        BarUtils.addMarginTopEqualStatusBarHeight(toolbar);

        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationIcon(R.mipmap.base_back_white);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressedSupport();
            }
        });

    }


    protected abstract String setTitle();

}
